<extend name="Index:index" />
    <block name="nav1">
        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Admin</a>
            </li>
            <li class="active">课程管理</li>
        </ul><!-- .breadcrumb -->
    </block>

    <block name="nav2">
        <h1>
        课程管理
            <small>
                <i class="icon-double-angle-right"></i>
                <{$action}>
            </small>
<!--             <ii class="add_list" style="font-size:16px; color:black; cursor:pointer; padding:5px;"><span><img src="__PUBLIC__/admin/image/t01.png" /></span>&nbsp;添加</ii>
 -->       
 		 </h1>
        <if condition="$class">
   		<table class="table table-bordered h5 tb">
   			<tr>
   				<th>分类ID</th>
   				<th>分类名称</th>
   				<th>显示排序</th>
   				<th>操作</th>
   			</tr>
   			<foreach name="class" item="vo" key="k">
   			<tr class="alt" >
   				<td><{$vo.id}></td>
   				<td><{$vo.name}></td>
   				<td><{$vo.paixu}></td>
   				<td>
					<a href="<{:U('Course/add_class',array('type'=>1,'id'=>$vo['id'],'sign'=>$_GET['sign']))}>">编辑</a>&nbsp;&nbsp; 
					<a id=" jh" onclick="del(<{$vo.id}>, <{$k}>,'course_list')" style="cursor:pointer">删除</a>&nbsp;&nbsp; 
				</td>
   			</tr>
   			</foreach>
   			<tr class="alt"><td colspan="4"><!-- <a class="add_btn">添加</a> --><ii class="add_btn" style="font-size:16px; color:black; cursor:pointer; padding:5px;"><span><img src="__PUBLIC__/admin/image/t01.png" /></span>&nbsp;添加</ii></td></tr>
   		</table>
   		</if>
    </block>
	
    <block name="main">
        <div class="row">
       		<form action="" method="post">
       		课程分类：
       			<if condition="$_GET['sign']==0">
       			
       			<select name="type_one" style="margin-right:15px;" >
                     <option value="">全部</option>   	
                 	<foreach name="class_1" item="vo">
                 		<option value="<{$vo.id}>" <if condition="$where['type_one'] eq $vo['id']">selected="selected"</if>><{$vo.name}></option>
                 	</foreach>
                 </select>
                 <select name="type_two" >
                 	<option value="" class="speci">全部</option>
                 	<foreach name="class_two" item="vo">
                 		<option value="<{$vo.id}>" <if condition="$where['type_two'] eq $vo['id']">selected="selected"</if>><{$vo.name}></option>
                 	</foreach>
                 </select>&nbsp;&nbsp;
       			<else/>
       			<select name="type_two" style="">
	        		<option value="">全部</option>
	        		<foreach name="class" item="vo" key="k">
					<option value="<{$vo.id}>" <if condition="$where['type_two'] eq $vo['id']">selected="selected"</if>><{$vo.name}></option>
					</foreach>
				</select>&nbsp;&nbsp;
				</if>
				课程级别：
	        	<select name="type_three" style="">
	        		<option value="">全部</option>
					<option value="1" <if condition="$where['type_three'] eq 1">selected="selected"</if>>初级</option>
					<option value="2" <if condition="$where['type_three'] eq 2">selected="selected"</if>>中级</option>
					<option value="3" <if condition="$where['type_three'] eq 3">selected="selected"</if>>高级</option>
				</select>&nbsp;&nbsp;
				课程名称：<input type="text" name="course_name" <if condition="$where">value="<{$where.course_name}>"</if>/>&nbsp;&nbsp;
				<input type="submit" value="查询" class="btn"/>			
			</form>
             <table class="table table-bordered h5 tb">
                <tr>
                	<th width="1%">ID</th>
                    <th width="5%">课程名称</th>
                    <th width="6%">所属分类</th>
                    <th width="6%">课程类型</th>
                    <th width="3%">上课时间</th>
                    <th width="3%">结束时间</th>
                    <th width="3%">停留时间</th>
                    <th width="6%">上课地点</th>
                    <th width="3%">图片</th>
                    <th width="10%">课程简介</th>
                    <th width="4%">讲师</th>
                    <th width="3%">点击次数</th>
                    <th width="3%">可报名人数</th>
                    <th width="3%">已报名人数</th>
                    <th width="5%">报名状态</th>
                    <th width="5%">课程状态</th>
                    <!-- <th width="5%">直播接口</th> -->
                    <th width="3%">是否为公开课</th>
                    <th width="3%">发布时间</th>
                    <th width="8%">操作</th>
                </tr>
                <foreach name="list" item="vo" key="k">
                <tr class="alt" id="list<{$k}>">
                    <!-- <td colspan="2"></td> -->
                    <td><{$vo.id}></td>
                    <td><{$vo.course_name}></td>
                    <td><{$vo.type_one}>-<{$vo.type_two}></td>
                    <td><{$vo.course_type}></td>
                    <td><{$vo.start_time}></td>
                    <td><{$vo.end_time}></td>
                    <td><{$vo.stop_time}></td>
                    <td><{$vo.course_area}></td>
                    <td><img style="width:30px; height:30px;" src="__ROOT__/<{$vo.course_logo}>"/></td>
                    <td><{$vo.introduce}></td>
                    <td><{$vo.lecturer}></td>
                    <td><{$vo.click_people}></td>
                    <td><{$vo.enroll_limit}></td>
                    <td><{$vo.enroll_people}></td>
                    <!-- <td><{$vo.enroll_status}></td> -->
                    <td>
                    	<if condition="$vo['enroll_status'] eq 0">
                    	未开始
                    	<elseif condition="$vo['enroll_status'] eq 1"/>
                    	已开始
                    	<else/>
                    	已结束
                    	</if>
                    </td>
                    <!-- <td><{$vo.course_status}></td> -->
                    <td>
                    	<if condition="$vo['course_status'] eq 0">
                    	未开始
                    	<elseif condition="$vo['course_status'] eq 1"/>
                    	进行中
                    	<else/>
                    	已结束
                    	</if>
                    </td>
                    <!-- <td><if condition="$vo['if_live'] eq 1"><{$vo.live_url}><else/>无直播</if></td>
                     -->
                    <td>
                    	<if condition="$vo['if_public'] eq 0">
                    	否
                    	<else/>
                    	是</if>
                    </td>
                    <td><{$vo.add_time}></td>
					<td>
						<a href="<{:U('Course/class_staff',array('c_id'=>$vo['id']))}>">报名信息</a><br/>
						<a href="<{:U('Course/comment',array('c_id'=>$vo['id']))}>">留言信息</a><br/>
						<a href="<{:U('Course/collect',array('c_id'=>$vo['id']))}>">收藏信息</a><br/>
						<a href="<{:U('Course/add_course',array('type'=>1,'id'=>$vo['id'],'sign'=>$_GET['sign']))}>">编辑</a>
						<a id=" jh" onclick="del(<{$vo.id}>, <{$k}>,'course')" style="cursor:pointer">删除</a>
					</td>
            	   
                </tr>
                </foreach> 
            </table>
            <div class="pages"><{$page}></div>
        </div>
         <script>
    	$(function(){
    		/* //添加课程 
    		$(".add_list").click(function(){
    			window.location.href="__APP__/Admin/Course/add_course";
    		}); */
    		//添加分类 
    		$(".add_btn").click(function(){
    			
    			window.location.href="__APP__/Admin/Course/add_class?sign="+<{$_GET['sign']}>;
    		});
    	});
    	//删除操作 
		function del($id,$k,$table){
			var table=$table;
			var data="table="+table+"&id="+$id;
			var obj="#list"+$k;
			obj=$(obj);
			
			$.ajax({
				url:"<{:U('Course/del')}>",
				type:"post",
				data:data,
				success:function(data){
					if(data){
						/* obj.html(""); */
						alert("删除成功");
						window.location.href=data;
						
					}else{
						alert("删除失败");
					}
				},
				error:function(data){
					alert("删除失败");
				}
			});
		}
    	
    	
    </script>
        <script>
    $(function(){
    	
    	$('[name="type_one"]').change(function(){
    		var pid=$(this).val();
    		/* if(pid==""){
    			
    			$('[name="type_two"]').value="";//有bug
    		}else{ */
   			var data="pid="+pid;
       		$.ajax({
       			url:"<{:U('Course/sel_class')}>",
       			type:"post",
       			data:data,
       			dataType:"json",
       			success:function(data){
       				$('[name="type_two"]').html("");
       				var o='<option value="" class="speci">全部</option>';
   					$('[name="type_two"]').prepend(o);
       				if(data){
       					$.each(data,function(i,val){
       						var obj='<option value="'+val['id']+'"';
       						if('<{$where['type_two']}>'== val['id']){
       							obj+='selected="selected"';
       						}
       						obj+='>'+val['name']+'</option>';
       						
       						$('[name="type_two"]').append(obj);
       					});
       					
       				}
       				
       			}
       			
       		});
    		/* } */
    		
    	});
    	
    });
    
    </script>
    <script></script>
    </block>
